package part16_备忘录模式_游戏角色恢复.p02_游戏角色恢复状态;

/**
 * @ClassName: GameRole
 * @Author: AllenSun
 * @Date: 2020/3/8 23:39
 */
public class GameRole {

    private int vit;
    private int def;

    //创建Memento，就是根据当前的状态得到memento
    public Memento createMemento(){
        return new Memento(vit,def);
    }

    //从备忘录对象，付汇GameRole的状态
    public void recoverGameRoleFromMemento(Memento memento){
        this.vit=memento.getVit();
        this.def=memento.getDef();
    }

    //显示当前游戏角色的状态
    public void display(){
        System.out.println("游戏角色当前的攻击力："+this.vit+"防御力："+this.def);
    }

    public int getVit() {
        return vit;
    }

    public void setVit(int vit) {
        this.vit = vit;
    }

    public int getDef() {
        return def;
    }

    public void setDef(int def) {
        this.def = def;
    }
}
